import React from "react";

import BaseComponent from "../BaseComponent";

export default class File extends BaseComponent {

    static defaultProps = {
        accept: ''
    };

    constructor(props) {
        super(props);
    }

    _onChange(e) {
        if (this.props.onChange) {
            this.props.onChange(this._file.files[0]);
        }
    }

    render() {

        return (
            <input ref={(o) => this._file = o}
                   type="file" accept={this.props.accept}
                   onChange={this._onChange.bind(this)}/>
        )
    }
}
